home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / mint96sb.zoo / doc / mintbind.h < prev    next >
C/C++ Source or Header  |  1992-10-18  |  8KB  |  256 lines

  1. #ifndef _MINTBIND_H
  2. #define _MINTBIND_H
  3.  
  4. #ifdef __TURBOC__
  5. # ifndef __TOS
  6. #  include <tos.h>
  7. # endif
  8. #else
  9. #ifndef _OSBIND_H
  10. #include <osbind.h>
  11. #endif
  12. #endif
  13.  
  14. #ifdef __GNUC_INLINE__
  15. #define trap_1_wwlw(n, a, b, c)                        \
  16. ({                                    \
  17.     register long retvalue __asm__("d0");                \
  18.     short _a = (short)(a);                        \
  19.     long  _b = (long) (b);                        \
  20.     short  _c = (short) (c);                    \
  21.                                         \
  22.     __asm__ volatile                        \
  23.     ("\
  24.         movw    %4,sp@-; \
  25.         movl    %3,sp@-; \
  26.         movw    %2,sp@-; \
  27.         movw    %1,sp@-; \
  28.         trap    #1;    \
  29.         lea    10(sp),sp "                    \
  30.     : "=r"(retvalue)            /* outputs */        \
  31.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  32.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  33.     );                                \
  34.     retvalue;                            \
  35. })
  36.  
  37. #define trap_1_wwww(n, a, b, c)                        \
  38. ({                                    \
  39.     register long retvalue __asm__("d0");                \
  40.     short _a = (short)(a);                        \
  41.     short  _b = (short)(b);                        \
  42.     short  _c = (short)(c);                        \
  43.                                         \
  44.     __asm__ volatile                        \
  45.     ("\
  46.         movw    %4,sp@-; \
  47.         movw    %3,sp@-; \
  48.         movw    %2,sp@-; \
  49.         movw    %1,sp@-; \
  50.         trap    #1;    \
  51.         addqw    #8,sp " \
  52.     : "=r"(retvalue)            /* outputs */        \
  53.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  54.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  55.     );                                \
  56.     retvalue;                            \
  57. })
  58.  
  59. #define trap_1_wwwl(n, a, b, c)                        \
  60. ({                                    \
  61.     register long retvalue __asm__("d0");                \
  62.     short _a = (short)(a);                        \
  63.     short  _b = (short)(b);                        \
  64.     long  _c = (long)(c);                        \
  65.                                         \
  66.     __asm__ volatile                        \
  67.     ("\
  68.         movl    %4,sp@-; \
  69.         movw    %3,sp@-; \
  70.         movw    %2,sp@-; \
  71.         movw    %1,sp@-; \
  72.         trap    #1;    \
  73.         lea     sp@(10),sp "                    \
  74.     : "=r"(retvalue)            /* outputs */        \
  75.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  76.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  77.     );                                \
  78.     retvalue;                            \
  79. })
  80.  
  81. #define trap_1_wwl(n, a, b)                        \
  82. ({                                    \
  83.     register long retvalue __asm__("d0");                \
  84.     short _a = (short)(a);                        \
  85.     long  _b = (long) (b);                        \
  86.                                         \
  87.     __asm__ volatile                        \
  88.     ("\
  89.         movl    %3,sp@-; \
  90.         movw    %2,sp@-; \
  91.         movw    %1,sp@-; \
  92.         trap    #1;    \
  93.         addqw    #8,sp "                    \
  94.     : "=r"(retvalue)            /* outputs */        \
  95.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  96.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  97.     );                                \
  98.     retvalue;                            \
  99. })
  100.  
  101. #else
  102.  
  103. #ifdef __GNUC__
  104. # ifndef __MSHORT__
  105. #  define __LONG_TRAPS__
  106. # endif
  107. #endif
  108.  
  109. #ifndef __LONG_TRAPS__
  110. # ifndef trap_1_w
  111. #  define trap_1_w(n)        gemdos(n)
  112. #  define trap_1_wl(n,a)        gemdos(n, (long)(a))
  113. #  define trap_1_wll(n, a, b)    gemdos(n, (long)(a), (long)(b))
  114. #  define trap_1_ww(n,a)        gemdos(n, a)
  115. #  define trap_1_www(n,a,b)    gemdos(n, a, b)
  116. #  define trap_1_wwlll(n,a,b,c,d) gemdos(n, a, (long)(b), (long)(c), (long)(d))
  117. #  define trap_1_wwll(n, a, b, c)    gemdos(n, a, (long)(b), (long)(c))
  118. #  define trap_1_wlw(n, a, b)    gemdos(n, (long)(a), b)
  119. #  define trap_1_wlww(n, a, b, c)    gemdos(n, (long)(a), b, c)
  120. #  define trap_13_w(n)        bios(n)
  121. #  define trap_14_w(n)        xbios(n)
  122. # endif
  123. # define trap_1_wwlw(n,a,b,c)    gemdos(n, a, (long)(b), c)
  124. # define trap_1_wwww(n,a,b,c)    gemdos(n, a, b, c)
  125. # define trap_1_wwl(n, a, b)    gemdos(n, a, (long)(b))
  126. # define trap_1_wwwl(n,a,b,c)    gemdos(n, a, b, (long)(c))
  127. #endif /* __LONG_TRAPS__ */
  128.  
  129. #endif /* __GNUC_INLINE__ */
  130.  
  131. /* note: none of these functions is declared as (void), despite
  132.  * what the man pages say; this is so that programs can check
  133.  * for a -32 return error from TOS if MiNT is not installed
  134.  */
  135.  
  136. #define    Syield()                        \
  137.         (short)trap_1_w(0xff)
  138. #define Fpipe(ptr)                        \
  139.         (short)trap_1_wl(0x100, (long)(ptr))
  140. #define Fcntl(f, arg, cmd)                    \
  141.         trap_1_wwlw(0x104, (short)(f), (long)(arg), (short)(cmd))
  142. #define Finstat(f)                        \
  143.         trap_1_ww(0x105, (short)(f))
  144. #define Foutstat(f)                        \
  145.         trap_1_ww(0x106, (short)(f))
  146. #define Fgetchar(f, mode)                    \
  147.         trap_1_www(0x107, (short)(f), (short)(mode))
  148. #define Fputchar(f, ch, mode)                    \
  149.         trap_1_wwlw(0x108, (short)(f), (long)(ch), (short)(mode))
  150.  
  151. #define Pwait()                            \
  152.         trap_1_w(0x109)
  153. #define Pnice(delta)                        \
  154.         (short)trap_1_ww(0x10a, (short)(delta))
  155. #define Pgetpid()                        \
  156.         (short)trap_1_w(0x10b)
  157. #define Pgetppid()                        \
  158.         (short)trap_1_w(0x10c)
  159. #define Pgetpgrp()                        \
  160.         (short)trap_1_w(0x10d)
  161. #define Psetpgrp(pid, grp)                    \
  162.         (short)trap_1_www(0x10e, (short)(pid), (short)(grp))
  163. #define Pgetuid()                        \
  164.         (short)trap_1_w(0x10f)
  165. #define Psetuid(id)                        \
  166.         (short)trap_1_ww(0x110, (short)(id))
  167. #define Pkill(pid, sig)                        \
  168.         (short)trap_1_www(0x111, (short)(pid), (short)(sig))
  169. #define Psignal(sig, handler)                    \
  170.         trap_1_wwl(0x112, (short)(sig), (long)(handler))
  171. #define Pvfork()                        \
  172.         (short)trap_1_w(0x113)
  173. #define Pgetgid()                        \
  174.         (short)trap_1_w(0x114)
  175. #define Psetgid(id)                        \
  176.         (short)trap_1_ww(0x115, (short)(id))
  177. #define Psigblock(mask)                        \
  178.         trap_1_wl(0x116, (unsigned long)(mask))
  179. #define Psigsetmask(mask)                    \
  180.         trap_1_wl(0x117, (unsigned long)(mask))
  181. #define Pusrval(arg)                        \
  182.         trap_1_wl(0x118, (long)(arg))
  183. #define Pdomain(arg)                        \
  184.         (short)trap_1_ww(0x119, (short)(arg))
  185. #define Psigreturn()                        \
  186.         (short)trap_1_w(0x11a)
  187. #define Pfork()                            \
  188.         (short)trap_1_w(0x11b)
  189. #define Pwait3(flag, rusage)                    \
  190.         trap_1_wwl(0x11c, (short)(flag), (long)(rusage))
  191. #define Fselect(time, rfd, wfd, xfd)                \
  192.         (short)trap_1_wwlll(0x11d, (unsigned short)(time), (long)(rfd), \
  193.                 (long)(wfd), (long)(xfd))
  194. #define Prusage(rsp)                        \
  195.         (short)trap_1_wl(0x11e, (long)(rsp))
  196. #define Psetlimit(i, val)                    \
  197.         trap_1_wwl(0x11f, (short)(i), (long)(val))
  198.  
  199. #define Talarm(sec)                        \
  200.         trap_1_wl(0x120, (long)(sec))
  201. #define Pause()                            \
  202.         (short)trap_1_w(0x121)
  203. #define Sysconf(n)                        \
  204.         trap_1_ww(0x122, (short)(n))
  205. #define Psigpending()                        \
  206.         trap_1_w(0x123)
  207. #define Dpathconf(name, which)                    \
  208.         trap_1_wlw(0x124, (long)(name), (short)(which))
  209.  
  210. #define Pmsg(mode, mbox, msg)                    \
  211.         trap_1_wwll(0x125, (short)(mode), (long)(mbox), (long)(msg))
  212. #define Fmidipipe(pid, in, out)                    \
  213.         trap_1_wwww(0x126, (short)(pid), (short)(in),(short)(out))
  214. #define Prenice(pid, delta)                    \
  215.         (short)trap_1_www(0x127, (short)(pid), (short)(delta))
  216. #define Dopendir(name, flag)                    \
  217.         trap_1_wlw(0x128, (long)(name), (short)(flag))
  218. #define Dreaddir(len, handle, buf)                \
  219.         trap_1_wwll(0x129, (short)(len), (long)(handle), (long)(buf))
  220. #define Drewinddir(handle)                    \
  221.         trap_1_wl(0x12a, (long)(handle))
  222. #define Dclosedir(handle)                    \
  223.         trap_1_wl(0x12b, (long)(handle))
  224. #define Fxattr(flag, name, buf)                    \
  225.         trap_1_wwll(0x12c, (short)(flag), (long)(name), (long)(buf))
  226. #define Flink(old, new)                        \
  227.         trap_1_wll(0x12d, (long)(old), (long)(new))
  228. #define Fsymlink(old, new)                    \
  229.         trap_1_wll(0x12e, (long)(old), (long)(new))
  230. #define Freadlink(siz, buf, linknm)                \
  231.         trap_1_wwll(0x12f, (short)(siz), (long)(buf), (long)(linknm))
  232. #define Dcntl(cmd, name, arg)                    \
  233.         trap_1_wwll(0x130, (short)(cmd), (long)(name), (long)(arg))
  234. #define Fchown(name, uid, gid)                    \
  235.         trap_1_wlww(0x131, (long)(name), (short)(uid), (short)(gid))
  236. #define Fchmod(name, mode)                    \
  237.         trap_1_wlw(0x132, (long)(name), (short)(mode))
  238. #define Pumask(mask)                        \
  239.         (short)trap_1_ww(0x133, (short)(mask))
  240. #define Psemaphore(mode, id, tmout)                \
  241.         trap_1_wwll(0x134, (short)(mode), (long)(id), (long)(tmout))
  242. #define Dlock(mode, drive)                    \
  243.         trap_1_www(0x135, (short)(mode), (short)(drive))
  244. #define Psigpause(mask)                        \
  245.         (short)trap_1_wl(0x136, (unsigned long)(mask))
  246. #define Psigaction(sig, act, oact)                \
  247.         trap_1_wwll(0x137, (short)(sig), (long)(act), (long)(oact))
  248. #define Pgeteuid()                        \
  249.         (short)trap_1_w(0x138)
  250. #define Pgetegid()                        \
  251.         (short)trap_1_w(0x139)
  252. #define Pwaitpid(pid,flag, rusage)                \
  253.         trap_1_wwwl(0x13a, (short)(pid), (short)(flag), (long)(rusage))
  254.  
  255. #endif /* _MINTBIND_H */
  256.